package com.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

//@WebServlet(name = "ano",urlPatterns = "/Ano")
@WebServlet("/Ano")
public class ServletByAno extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //完成主要的业务

        resp.setContentType("text/html;charset=utf-8");

        PrintWriter out = resp.getWriter();
        out.println("servlet by annotation<br>");

        out.print("<font style='color:red'>不经一番寒彻骨，哪得梅花扑鼻香！</font>");
//        resp.sendRedirect("login.jsp");//在Servlet 调转jsp
        resp.sendRedirect("Ano2");


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doGet(req,resp);
    }
}
